<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>
        // 返回两个⽇期之间相差的天数
        function Dater(times){
            var day1 = new Date(times);
            var day2 = new Date();
            var time = (day1-day2)/1000;
            var t = parseInt(time / 60 / 60 / 24);
            t = t < 10? '0' + t : t;
            var s = parseInt(time / 60 /60 % 24);
            s = s < 10? '0' + s : s;
            var f = parseInt(time / 60 % 24);
            f = f < 10? '0' + f : f;
            var m = parseInt(time % 60);
            m = m < 10? '0' + m : m;
            return '还有' + t + "天" + s +'时' + f + '分' + m + '秒'; 
        }
        console.log(Dater('2022-10-20 00:00:00'));
        var dateY = new Date();
        console.log(dateY);
    </script>
</body>
</html>